#pragma once

#include<iostream>
#include<pthread.h>
#include "Mutex.hpp"

namespace condModule
{
    using namespace mutexModule;
    class Cond
    {
        public:
        Cond()
        {
            int n = ::pthread_cond_init(&_cond,  nullptr);
            (void)n;
        }
        void wait(Mutex& mutex) // 让我们的线程释放曾经所持有的锁
        {
            int n = ::pthread_cond_wait(&_cond, mutex.lockPtr());
            (void)n;
        }
        void notify()
        {
            int n = ::pthread_cond_signal(&_cond);
            (void)n;
        }
        void notifyAll()
        {
            int n = ::pthread_cond_broadcast(&_cond);
            (void)n;
        }
        ~Cond()
        {
            int n = ::pthread_cond_destroy(&_cond);
            (void)n;
        }
        private:
            pthread_cond_t _cond;
    };
}

// zdl:: 时间的形式